<!DOCTYPE html>
<html lang="en" ng-app="test">
<head>
	<meta charset="UTF-8">
	<title>过滤器</title>
</head>
<body ng-controller="ctr">
	<!-- <div>	
		{{aa|currency:"￥"}}
	</div>

	<div>	
	{{bb|lowercase}}
	</div> -->

	<ul>
		<li ng-repeat="a in persons|unique:'sex'">
			{{a}}
		</li>
	</ul>

</body>
<script type="text/javascript" src="../shop/js/angular.min.js"></script>
<script type="text/javascript">

	var app = angular.module("test",["sexFilter"]);
	app.controller("ctr",function($scope){
		 $scope.persons = [
		 {name:"gxm",sex:"男"},
		 {name:"abc",sex:"女"},
		 {name:"eda",sex:"男"},
		 {name:"hah",sex:"女"},
		 {name:"ui",sex:"男"}];
	});

	// 自定义过滤器
	var filters = angular.module("sexFilter",[]);
	filters.filter("unique",function(){

		return function(data,property){
			if (angular.isArray(data)) {
				
				var sexs = [];
				for (var i = 0; i < data.length; i++) {
						if (sexs.indexOf(data[i][property]) == -1) {
							sexs.push(data[i][property]);
						}
				};
				return sexs;

			}else{
				return [];
			}
		};


	});










</script>

</html>